/**
 * 
 */
package com.huarui.desktop;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.ewaf.framework.action.BaseAction;

import com.huarui.desktop.model.ModuleScript;
import com.huarui.desktop.model.ModuleScriptDesc;
import com.huarui.desktop.service.ModuleScriptBuilder;
import com.huarui.desktop.service.ModuleScriptDesigner;
import com.opensymphony.xwork2.Action;

/**
 * @author sunpeng
 * 
 */
public class ModuleScriptAction extends BaseAction {

	private static final long serialVersionUID = -6434256811394363647L;
	private Logger logger = Logger.getLogger(ModuleScriptAction.class);
	private ModuleScriptDesc desc;
    private ModuleScriptDesigner moduleScriptDesigner;
    
	public String generate() {
		
		ModuleScriptBuilder builder=moduleScriptDesigner.getScriptBuilder(null);
		moduleScriptDesigner.order(desc, builder);
		ModuleScript script=builder.getModuleScript();
		logger.info(script.description());
		ServletActionContext.getContext().put("script", script);
		//org.apache.commons.lang.StringUtils.j
		return Action.SUCCESS;
	}

	public ModuleScriptDesc getDesc() {
		return desc;
	}

	public void setDesc(ModuleScriptDesc desc) {
		this.desc = desc;
	}

	public void setModuleScriptDesigner(ModuleScriptDesigner moduleScriptDesigner) {
		this.moduleScriptDesigner = moduleScriptDesigner;
	}
	
}
